<template>
  <el-table :data="top5" style="padding-top: 15px;">
    <el-table-column label="ID"  align="center" type="index" :index="indexMethod">
     
    </el-table-column>
    <el-table-column :label="tabletitle"  align="center">
        <template slot-scope="scope">
        {{ scope.row[0] }}
      </template>
    </el-table-column>
    <el-table-column label="违规条数"  align="center">
 <template slot-scope="{row}">
        <el-tag :type="row.status | statusFilter">
          {{ row[1] }}
        </el-tag>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
import { transactionList } from '@/api/remote-search'

export default {
  props: {
    top5: {
      // type: Array,
      required: true
    },
    tabletitle:{
      required: true
    }
  },
   watch: {
    top5: {
      deep: true,
      handler(val) {
        // alert(123)
        this.top5 = val
      }
    },
    tabletitle: {
      deep: true,
      handler(val) {
        alert(val)
        this.title = val
      }
    }
  },
  filters: {
    statusFilter(status) {
      const statusMap = {
        success: 'success',
        pending: 'danger'
      }
      return statusMap[status]
    },
    // orderNoFilter(str) {
    //   return str.substring(0, 30)
    // }
  },
  data() {
    return {
      title: '',
      list: null,
      top5: {}
    }
  },
  created() {
    // this.fetchData()
  },
  methods: {
    indexMethod(index) {
        return index + 1;
      },
    fetchData() {
      transactionList().then(response => {
        // this.list = response.data.items.slice(0, 5)
         this.list = response.data.items
      })
    }
  }
}
</script>
